using System.Collections.Generic;
using System.ServiceModel;

namespace Hinacom.Scheduler.Service
{
    /// <summary>
    /// Service interface for Scheduler.
    /// </summary>
    [ServiceContract]
    public interface ISchedulerService
    {
        /// <summary>
        /// Initializes the instance of <see cref="ISchedulerService"/>.
        /// Initialization will only be called once in server's lifetime.
        /// </summary>
        [OperationContract]
        void Initialize();

        /// <summary>
        /// Starts this instance.
        /// </summary>
        [OperationContract]
        void Start();

        /// <summary>
        /// Stops this instance.
        /// </summary>
        [OperationContract]
        void Stop();

        /// <summary>
        /// Pauses all activity in scheduler.
        /// </summary>
        void Pause();

        /// <summary>
        /// Resumes all activity in server.
        /// </summary>
        void Resume();
        /// <summary>
        /// Creates a job in scheduler.
        /// </summary>
        /// <param name="job">The information and schedule of the job.</param>
        [OperationContract]
        void CreateJob(JobInfo job, bool overwrite);
        /// <summary>
        /// Deletes a job from scheduler.
        /// </summary>
        /// <param name="jobName">The name of the job.</param>
        /// <param name="jobGroup">The group that the job belongs to.</param>
        [OperationContract]
        void DeleteJob(string jobName, string jobGroup);
        /// <summary>
        /// Gets all active jobs in scheduler.
        /// </summary>
        /// <returns>A list of JobInfo objects.</returns>
        [OperationContract]
        IEnumerable<JobInfo> GetActiveJobs();
        /// <summary>
        /// Gets the running history of a specific job.
        /// </summary>
        /// <param name="jobName">The name of the job.</param>
        /// <param name="jobGroup">The group to that the job belongs.</param>
        /// <returns>The running history of the job.</returns>
        [OperationContract]
        IEnumerable<JobHistory> GetJobHistories(string jobName, string jobGroup, int? lastLoadedId);
        /// <summary>
        /// Gets the detail log of a job running history record.
        /// </summary>
        /// <param name="historyId">The id of the history</param>
        /// <returns>The detial running log.</returns>
        [OperationContract]
        string GetJobHistoryLog(int historyId);
    }
}
